home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo6.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  6.4 KB  |  171 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9.  
  10. /***********************************************************************/
  11.  
  12. long __stack = 8192;
  13. struct Library *MUIMasterBase;
  14.  
  15. /***********************************************************************/
  16.  
  17. #ifndef MAKE_ID
  18. #define MAKE_ID(a,b,c,d) ((ULONG)(a)<<24|(ULONG)(b)<<16|(ULONG)(c)<<8|(ULONG)(d))
  19. #endif
  20.  
  21. /***********************************************************************/
  22.  
  23. #define ROWS      3
  24. #define COLS     16
  25. #define HSPACE    0
  26. #define VSPACE    0
  27. #define PIC(x,y) (x+y*COLS)
  28.  
  29. #define BAR {MUIV_TheBar_BarSpacer}
  30.  
  31. struct MUIS_TheBar_Button buttons[] =
  32. {
  33.     {PIC(7,0),  1, "_Face",  "Just a face."},
  34.     {PIC(14,0), 2, "_Mouse", "Your mouse."},
  35.     {PIC(1,1),  3, "_Tree",  "Mind takes place."},
  36.  
  37.     BAR,
  38.  
  39.     {PIC(10,1), 4, "_Help",  "Read this!."},
  40.     {PIC(2,2),  5, "_ARexx", "ARexx for ever!."},
  41.     {PIC(1,0),  6, "_Host",  "Your computer."},
  42.  
  43.     MUIV_TheBar_End,
  44. };
  45.  
  46. /***********************************************************************/
  47.  
  48. char *appareances[] = {"Images and text","Images","Text",NULL};
  49. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  50.  
  51. int
  52. main(int argc,char **argv)
  53. {
  54.     int res;
  55.  
  56.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  57.     {
  58.         Object *app, *win, *sb, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  59.  
  60.         if (app = ApplicationObject,
  61.                 MUIA_Application_Title,         "TheBar Demo6",
  62.                 MUIA_Application_Version,       "$VER: TheBarDemo6 1.0 (24.6.2003)",
  63.                 MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
  64.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  65.                 MUIA_Application_Description,  "TheBar example",
  66.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  67.  
  68.                 SubWindow, win = WindowObject,
  69.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  70.                     MUIA_Window_Title,          "TheBar Demo6",
  71.                     WindowContents, VGroup,
  72.                         Child, sb = TheBarObject,
  73.                             GroupFrame,
  74.                             MUIA_Group_Horiz,            TRUE,
  75.                             MUIA_TheBar_EnableKeys,      TRUE,
  76.                             MUIA_TheBar_Buttons,         buttons,
  77.                             MUIA_TheBar_PicsDrawer,      "PROGDIR:Pics",
  78.                             MUIA_TheBar_Strip,           "symbols",
  79.                             MUIA_TheBar_StripCols,       COLS,
  80.                             MUIA_TheBar_StripRows,       ROWS,
  81.                             MUIA_TheBar_StripHorizSpace, HSPACE,
  82.                             MUIA_TheBar_StripVertSpace,  VSPACE,
  83.                         End,
  84.                         Child, VGroup,
  85.                             GroupFrameT("Settings"),
  86.                             Child, HGroup,
  87.                                 Child, Label2("Appareance"),
  88.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  89.                                 Child, Label2("Label pos"),
  90.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  91.                             End,
  92.                             Child, HGroup,
  93.                                 Child, HSpace(0),
  94.                                 Child, Label1("Borderless"),
  95.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  96.                                 Child, HSpace(0),
  97.                                 Child, Label1("Sunny"),
  98.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  99.                                 Child, HSpace(0),
  100.                                 Child, Label1("Raised"),
  101.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  102.                                 Child, HSpace(0),
  103.                                 Child, Label1("Scaled"),
  104.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  105.                                 Child, HSpace(0),
  106.                             End,
  107.                         End,
  108.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  109.                     End,
  110.                 End,
  111.             End)
  112.         {
  113.             ULONG sigs = 0, id;
  114.  
  115.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  116.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  117.  
  118.             set(win,MUIA_Window_Open,TRUE);
  119.  
  120.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  121.             {
  122.                 if (id==TAG_USER)
  123.                 {
  124.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  125.  
  126.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  127.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  128.                     get(borderless,MUIA_Selected,&borderlessV);
  129.                     get(sunny,MUIA_Selected,&sunnyV);
  130.                     get(raised,MUIA_Selected,&raisedV);
  131.                     get(scaled,MUIA_Selected,&scaledV);
  132.  
  133.                     SetAttrs(sb,MUIA_TheBar_ViewMode,   appareanceV,
  134.                                 MUIA_TheBar_LabelPos,   labelPosV,
  135.                                 MUIA_TheBar_Borderless, borderlessV,
  136.                                 MUIA_TheBar_Sunny,      sunnyV,
  137.                                 MUIA_TheBar_Raised,     raisedV,
  138.                                 MUIA_TheBar_Scaled,     scaledV,
  139.                                 TAG_DONE);
  140.                 }
  141.  
  142.                 if (sigs)
  143.                 {
  144.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  145.                     if (sigs & SIGBREAKF_CTRL_C) break;
  146.                 }
  147.             }
  148.  
  149.             MUI_DisposeObject(app);
  150.  
  151.             res = RETURN_OK;
  152.         }
  153.         else
  154.         {
  155.             printf("%s: can't create application\n",argv[0]);
  156.             res = RETURN_FAIL;
  157.         }
  158.  
  159.         CloseLibrary(MUIMasterBase);
  160.     }
  161.     else
  162.     {
  163.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  164.         res = RETURN_ERROR;
  165.     }
  166.  
  167.     return res;
  168. }
  169.  
  170. /***********************************************************************/
  171.